<template>
  <div>
    <div class="title">用户列表</div>
    <div class="table">
      <el-table
        v-loading="isloading"
        element-loading-text="拼命加载中"
        header-row-class-name="table-header"
        height="600"
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="userNum"
          label="用户编号"
          width="150">
        </el-table-column>
        <el-table-column
          prop="nickName"
          label="昵称"
          width="80">
        </el-table-column>
        <el-table-column
          prop="userPhone"
          label="电话 / 登陆账号"
          width="120">
        </el-table-column>
        <el-table-column
          prop="realName"
          label="真实姓名"
          width="80">
        </el-table-column>
        <el-table-column
          prop="bankCard"
          label="银行卡号"
          width="200">
        </el-table-column>
        <el-table-column
          prop="idCard"
          label="身份证号"
          width="200">
        </el-table-column>
        <el-table-column
          prop="areaName"
          label="所在城市"
          width="50">
        </el-table-column>
        <el-table-column
          prop="detailedAddress"
          label="详细地址"
          width="150">
        </el-table-column>
        <el-table-column
          prop="invitationCode"
          label="邀请码"
          width="90">
        </el-table-column>
        <el-table-column
          prop="type_name"
          label="受邀码"
          width="80">
        </el-table-column>
        <!--<el-table-column
          label="状态"
          class-name="status-font"
          width="50">
          <template slot-scope="scope">
            <i
            @click="setStatus(scope.$index, scope.row)"
            v-bind:class="scope.row.status ? 'el-icon-check' : 'el-icon-close'"
            v-bind:style="{color: scope.row.status ? '#13CE66' : '#FF4949'}">
            </i>
            <i class="el-icon-loading" v-if="scope.$index === isStatusLoading"></i>
          </template>
        </el-table-column>-->
        <!--<el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              size="mini"
              @click="edit(scope)">编辑</el-button>
            <del-picker
              :isdisabled="scope.row.id == '1'"
              v-on:remove="del(scope)"
              :fun="fun"
              :scope="scope">
            </del-picker>
          </template>
        </el-table-column>-->
      </el-table>
    </div>
    <div class="page">
      <div class="page-total">共
        <span class="page-total-num">{{pageConfig.total}}</span> 条
      </div>
      <div class="pages" v-if="pageConfig.total > 0">
        <el-pagination
          @size-change="setPageSize"
          background
          @current-change="toPage"
          :current-page="pageConfig.newPage"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageConfig.pageSize"
          layout="prev, pager, next, jumper"
          :total="pageConfig.total">
        </el-pagination>
      </div>
      <div class="clearfix"></div>
    </div>
  </div>
</template>

<script>
import {userList} from '../../api/person.js'
export default {
  data () {
    return {
      isStatusLoading: '',
      isloading: false,
      pageConfig: {
        newPage: 1,
        total: 0,
        pageSize: 10
      },
      tableData: [],
      getUserParmas: {
        start: 0,
        length: 10,
        search: ''
      }
    }
  },
  methods: {
    setStatus (val1, val2) {
      console.log(val1, val2)
    },
    setPageSize (val) {
      this.pageConfig.pageSize = this.getUserParmas.length = val
      this.userList()
    },
    toPage (val) {
      this.getUserParmas.start = (val - 1) * this.getUserParmas.length
      console.log(this.getUserParmas)
      this.userList()
    },
    async userList () {
      try {
        this.isloading = true
        let data = await userList(this.getUserParmas)
        this.tableData = data.data.data
        this.pageConfig.total = data.data.recordsTotal
        this.isloading = false
      } catch (err) {
        console.log(err)
      }
    }
  },
  created: function () {
    this.userList()
  }
}
</script>

<style scoped>
  .title{
    font-size: 22px;
    font-weight: 600;
  }
  .page{
    overflow: hidden;
    height: 35px;
    padding: 10px 20px;
  }
  .page-total{
    float: left;
    line-height: 35px;
  }
  .pages{
    float: right;
    line-height: 35px;
  }
  .clearfix{
    clear: both;
  }
</style>
